{extend name="public:base" /}


{block name="content"}

    <link rel="stylesheet" href="__CSS__/bootstrap-select.min.css">

	  <!-- 搜索 开始 -->
    <div class="back_btn">
        <!-- 返回按钮 -->
        <button class="btn btn_color" type="button" style="outline: none;">
            <a href="{:url('index')}"><span class="glyphicon glyphicon-arrow-left" style="color:#3c8dbc;font-size: 18px;"></span></a>
        </button>
        <button type="button" class="btn btn-info btn-xs pull-right " style="margin: 10px 10px;">
            <a href="{:url('index')}">返回首页</a>
        </button>
        <!-- 输入id查询 -->
        <div class="choose_btn">
            <a class="btn btn-primary" role="button" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
              筛选
            </a>
            <div class="collapse" id="collapseExample">
                <div class="well well_">
                    <!-- 输入id选择 -->
                    <!--<form method="get" action="{:url('fenpei')}">-->
                    <form method="get" action="{:url('fenpei_huisuo')}">
                    <div class="search d3">
                        <!--<input type="hidden" name="act" value="{$act}" >-->
                            <input type="text" name="id_phonenum" value="{$form.id_phonenum}" placeholder="请输入ID或手机号...">
                            <button type="submit"> <span class="glyphicon glyphicon-search" style="color:#e2b069;font-size: 18px;"></span></button>

                    </div>
                    <!-- 时间段选择 -->
                        <div id="reportrange" style=" cursor: pointer; width: 100%;margin-top: 10px;margin-bottom: 10px;">
                            <h6>建单时间：</h6>
                            <input type="text" name="jdtime" id="jdtime" value="{$form.jdtime}" class="form-control" placeholder="选择时间" style="height:35px;border:1px solid #e5e5e5;border-radius: 0px;outline: none;" />
                        </div>

                        <!-- 地区选择 -->

                        <div class="form-group" style="margin-top: 10px;">
                            <h6>地区：</h6>
                            <select class="form-control" name="area" id="area">
                                <option value="">全部</option>
                                {volist name='area' id='data'}
                                <option value="{$data.id}" {eq name="form['area']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                                {/volist}
                            </select>
                        </div>
                        <!-- 医院选择 -->

                        <div class="form-group" style="margin-top: 10px; position:relative;z-index: 1999;">
                            <h6>医院：</h6>
                            <select class="form-control selectpickers " name="yiyuan[]" id="yiyuan"  multiple  data-size="15"  >
                                <!--<option value="">全部</option>-->
                                {volist name='yiyuan' id='data'}
                                <option value="{$data.id}" {in name="data.id" value="$form['yiyuan']"}selected="selected"{/in} >{$data.name|msubstr=0,16}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="form-group" style="margin-top: 10px;">
                            <h6>状态：</h6>
                            <select class="form-control" name="ywstate">
                                <option value="">全部</option>
                                {volist name='ywstate' id='data'}
                                <option value="{$data.id}" {eq name="form['ywstate']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="form-group" style="margin-top: 10px;">
                            <h6>渠道：</h6>
                            <select class="form-control" name="qudao">
                                <option value="">全部</option>
                                {volist name='qudao' id='data'}
                                <option value="{$data.id}" {eq name="form['qudao']" value="$data.id"}selected="selected"{/eq} >{$data.name}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="form-group" style="margin-top: 10px;">
                            <h6>预产期：</h6>
                            <input type="text" name="yctime" id="yctime" value="{$form.yctime}" class="form-control" placeholder="选择时间" style="height:35px;border:1px solid #e5e5e5;border-radius: 0px;outline: none;" />
                        </div>
                    <!-- 筛选 -->
                    <button class="btn btn_choose" type="submit" style="outline: none;border:none;">按照以上条件筛选</button>    </form>
                </div>
            </div>
        </div>
       
    </div>
    <!-- 搜索 结束 -->
    <!-- 列表 action="{:url('fenpei')}" -->
    <form  id="commentForm" method="post" class="layui-form">
    <table class="table table-bordered table_color">
       <thead>
         <tr>
           <th>全选<br><input type="checkbox"  lay-skin="primary" lay-filter="allChoose" onclick="allSelect();"></th>
           <th>ID</th>
           <th>姓名</th>
           <th>妈妈电话</th>
           <th>建单时间</th>
           <th>医院</th>
           <th>状态</th>
         </tr>
       </thead>
       <tbody>
       {volist name='list' id="vo"  key="ev"  empty="暂时没有数据" }
         <tr role="button" style="background: none;"   >
           <td><input type="checkbox" name="ids[]" id="ids" lay-skin="primary" value="{$vo.id}"></td>
           <td>{$vo.id}</td>
           <td>{$vo.name}</td>
           <td>{$vo.maphone}</td>
           <td>{$vo.jdtime}</td>
           <td>{$vo.yyxx_text|msubstr=0,6}</td>
           <!--<td><span class="color{$vo.ywstate}">{$vo.state_text}</span></td>-->
           <td><span style="background-color: {$vo.color_text};">{$vo.state_text}</span></td>
         </tr>

       {/volist}

        </tbody>
    </table>
        <!--<input type="hidden" name="act" value="{$act}" >-->
        <!--<div  class="form-group" style="margin-top: 10px; margin-left: 20px;">-->
            <!--<label>活动会所：</label>-->
            <!--<select class="form-control" name="hsdzid" style="width: auto;display: inline">-->
                <!--<option value="">请选择会所</option>-->
                <!--{volist name='hdmd' id='data'}-->
                <!--<option value="{$data.id}" >{$data.title}</option>-->
                <!--{/volist}-->
            <!--</select>-->
            <!--<button class="btn btn-primary" type="submit"  style="background-color: #2ba6cb;width: auto;display: inline;margin-left: 7%;" >批量分配</button>-->
        <!--</div>-->
        <div  class="form-group" style="margin:10px auto;text-align:center;">
            <div class='col-sm-4 col-lg-4 col-md-4 col-xs-12' >
                <select class="form-control" name="hsdzid" id="hsdzid" style="width: 95%;display: inline;margin-top: 10px;">
                    <option value="">请选择会所</option>
                    {volist name='hdmd' id='data'}
                    <option value="{$data.id}" {eq name="form['hsdzid']" value="$data.id"}selected="selected"{/eq} >{$data.title}</option>
                    {/volist}
                </select>
            </div>
            <div class='col-sm-4 col-lg-4 col-md-4 col-xs-12' >
                <button class="btn btn-primary" type="submit"  style="background-color: #2ba6cb;width: 50%;display: inline;margin-top: 10px;" >批量分配</button>
            </div>
        </div>

        </form>
    <!-- 翻页 -->
    <div class="page_div">{$page}</div>
{/block}
{block name="js"}
<script type="text/javascript" src="__JS__/jquery-3.2.0.min.js"></script>
<script type="text/javascript" src="__JS__/bootstrap.min.js"></script>
<script type="text/javascript" src="__JS__/moment.js"></script>
<script type="text/javascript" src="__JS__/daterangepicker.js"></script>
<script type="text/javascript" src="__JS__/index.js"></script>


    <script type="text/javascript" src="__STATIC__/validate/jquery.validate.min.js"></script>
    <script type="text/javascript" src="__STATIC__/layer/layer.js"></script>
    <script type="text/javascript" src="__JS__/date.js"></script>
    <script type="text/javascript" src="__JS__/yewu.js"></script>

    <script type="text/javascript" src="__JS__/bootstrap-select.min.js"></script>

    <script type="text/javascript">
        $(function(){
            $('.selectpickers').selectpicker();

            var area = $('#area');
            var yiyuan = $('#yiyuan');
            area.change(function(){
                $.post("/admin/yewu/getyiyuan", {area:$(this).val()},function(data){
                    var optionstring = "";
                    if(data.code!=0){
                        $.each(data, function(i,item){
                            if(item.name.length > 16){
                                item.name = item.name.substr(0,16);
                            }
                            optionstring += "<option value=\"" + item.id + "\"  >" + item.name + "</option>";
                        });
                        $("#yiyuan").empty();
                        $("#yiyuan").append(optionstring);
                        $('.selectpickers').selectpicker('render');
                        $('.selectpickers').selectpicker('refresh');
                    }
                });
            });
        });
    </script>

    <script type="text/javascript">
        $(function() {

            var start = moment().subtract(29, 'days');
            var end = moment();

            function cb(start, end) {
                $('#reportrange input').val(start.format('YYYY/MM/DD') + ' - ' + end.format('YYYY/MM/DD'));
            }

            $('#reportrange').daterangepicker({
                startDate: start,
                endDate: end,
                ranges: {
                    '今天': [moment(), moment()],
                    '昨天': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                    '过去7天': [moment().subtract(6, 'days'), moment()],
                    '过去30天': [moment().subtract(29, 'days'), moment()],
                    '这个月': [moment().startOf('month'), moment().endOf('month')],
                    '上个月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')],
                },
                locale : {
                    applyLabel : '确定',
                    cancelLabel : '取消',
                    fromLabel : '起始时间',
                    toLabel : '结束时间',
                    customRangeLabel : '自定义',
                    // daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
                    // monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月',
                    // '七月', '八月', '九月', '十月', '十一月', '十二月' ],
                    // firstDay : 1
                }
            }, cb);

            cb(start, end);
            $('#reportrange input').val("{$form.jdtime}");
        });

    </script>
<script type="text/javascript">
    //全选，全不选
    function allSelect() {
        if ($(":checkbox").attr("checked") != "checked") {
            $(":checkbox").attr("checked", "checked");
        }
        else {
            $(":checkbox").removeAttr("checked");
        }
    }
    //反选
    function otherSelect() {
        $(":checkbox").each(function () {
            if ($(this).attr("checked") == "checked") {
                $(this).removeAttr("checked");
            }
            else {
                $(this).attr("checked", "checked");
            }
        });
    }
</script>
<script type="text/javascript">

    $().ready(function() {
        // 在键盘按下并释放及提交后验证提交表单
        $("#commentForm").validate({
            rules: {
                ids: { required:true},
                hsdzid: { required:true}
            },
            messages: {
                ids: "请选择单子!",
                hsdzid:"请选择会所!"
            },
            errorPlacement: function(error, element) {
                if (element.is(":input"))
                  error.appendTo(element.parent().next());
            },
            submitHandler: function(form)
            {
                $.ajax({
                    type: "POST",
//                    url:  "{:url('fenpei')}",
                    url:  "{:url('fenpei_huisuo')}",
                    data: $(form).serialize(),
                    beforeSend:function(){
                        $('#submit').attr("disabled","false"); //禁止点击
                    },
                    success: function(msg){
                        if(msg.icon==1){
                            $('#submit').attr("disabled","false"); //禁止点击
                            layer.msg(msg.msg, {icon: 1});
                            setTimeout(function(){
                                location.href=msg.url;
                            },3000); //延迟演示
                        }else{
                            layer.msg(msg.msg, {icon: 2});
                            $('#submit').removeAttr("disabled"); //禁止点击
                        }
                    }
                });
            }

        });
        return false;
    });
</script>
{/block}